layui.use(['form', 'layer', 'upload'], function() {
	$ = layui.jquery;
	var form = layui.form,
		layer = layui.layer,
		upload = layui.upload,
		element = layui.element;
	var s = "";
	console.log("进来了！！！");
	//拖拽上传
	var uploadInst = upload.render({
		elem: '#carPic',
		url: 'http://localhost:8888/usedcar/car/uploadImg?token='+document.cookie.split(";")[0],
		size: 1000,
		multiple: true,
		number: 7,
		before: function(obj) {
			//预读本地文件示例，不支持ie8
			obj.preview(function(index, file, result) {
				// $('#demo1').attr('src', result); //图片链接（base64）
				$('#see0').append('<img src="' + result +
					'" alt="' + file.name +
					'"height="100px" width="100px" class="layui-upload-img uploadImgPreView">')
			});
		},
		done: function(res) {
			var fileupload = $("#picture");
			fileupload.attr("value", res.data.src);
			console.log(fileupload.attr("value"));
			
			if (s == "") {
				s = JSON.stringify(res);
			} else {
				s = s + "," + JSON.stringify(res);
			};
			localStorage.setItem("address1", s);
		},
		error: function() {
			demoText.find('.demo-reload').on('click', function() {
				uploadInst.upload();
			});
		}
	
	});
	//拖拽上传
	var uploadInst = upload.render({
		elem: '#carPic1',
		url: 'http://localhost:8888/usedcar/car/uploadImg?token='+document.cookie.split(";")[0],
		size: 1000,
		multiple: true,
		number: 7,
		before: function(obj) {
			//预读本地文件示例，不支持ie8
			obj.preview(function(index, file, result) {
				// $('#demo1').attr('src', result); //图片链接（base64）
				$('#see1').append('<img src="' + result +
					'" alt="' + file.name +
					'"height="100px" width="100px" class="layui-upload-img uploadImgPreView">')
			});
		},
		done: function(res) {
			var fileupload = $("#picture1Path");
			fileupload.attr("value", res.data.src);
			console.log(fileupload.attr("value"));
			
			if (s == "") {
				s = JSON.stringify(res);
			} else {
				s = s + "," + JSON.stringify(res);
			};
			localStorage.setItem("address1", s);
		},
		error: function() {
			demoText.find('.demo-reload').on('click', function() {
				uploadInst.upload();
			});
		}
	
	});
	//拖拽上传
	var uploadInst = upload.render({
		elem: '#carPic2',
		url: 'http://localhost:8888/usedcar/car/uploadImg?token='+document.cookie.split(";")[0],
		size: 1000,
		multiple: true,
		number: 7,
		before: function(obj) {
			//预读本地文件示例，不支持ie8
			obj.preview(function(index, file, result) {
				// $('#demo1').attr('src', result); //图片链接（base64）
				$('#see2').append('<img src="' + result +
					'" alt="' + file.name +
					'"height="100px" width="100px" class="layui-upload-img uploadImgPreView">')
			});
		},
		done: function(res) {
			var fileupload = $("#picture2Path");
			fileupload.attr("value", res.data.src);
			console.log(fileupload.attr("value"));
			
			if (s == "") {
				s = JSON.stringify(res);
			} else {
				s = s + "," + JSON.stringify(res);
			};
			localStorage.setItem("address1", s);
		},
		error: function() {
			demoText.find('.demo-reload').on('click', function() {
				uploadInst.upload();
			});
		}
	
	});
});